let list = null
let hot = null
let newTxt = null
let myArticle = null
// user/userDataList
let userDataList = null
let userGood = null
async function get(obj) {
  myArticle = await axios({
    url: 'user/myArticle',
    headers: { token: localStorage.getItem('token') },
  }).then(res => {
    console.log(res)
    if (res.data.errmsg === '登陆验证失败，请重新登陆！') {
      layer.msg(res.data.errmsg)
      setTimeout(() => (location.href = '/web-static/login.html'), 1000)
      return
    }
    return res.data.data.data
  })
  list = await axios({
    url: 'index/index',
  }).then(res => {
    return res.data.data
  })
  hot = await axios({
    url: 'index/recommend',
  }).then(res => {
    return res.data.data
  })
  newTxt = await axios({
    url: 'index/hot',
  }).then(res => {
    return res.data.data
  })
  newShow = await axios({
    url: 'index/show',
    params: {
      id: obj,
    },
  }).then(res => {
    // console.log(res.data.data.info.isLike)
    return res.data.data
  })
  userDataList = await axios({
    url: 'user/userDataList',
    headers: { token: localStorage.getItem('token') },
    params: {
      type: 1,
    },
  }).then(res => {
    // console.log(res.data.data.list)
    return res.data.data.list
  })

  new Vue({
    el: '.shw',
    data: {
      allCate: list.allCate,
      banner: list.banner,
      sideBanner: list.sideBanner,
      allTag: list.allTag,
      allLink: list.allLink,
      list: hot.list,
      newlist: newTxt.list,
      token: localStorage.getItem('token'),
      user: localStorage.getItem('user')
        ? JSON.parse(localStorage.getItem('user'))
        : null,
      myArticle,
    },
    filters: {
      www(val) {
        let day = new Date(val).getDate()
        day = day < 10 ? '0' + day : day
        let m = new Date(val).getMonth() + 1
        m = m < 10 ? '0' + m : m
        let y = new Date(val).getFullYear()
        y = y < 10 ? '0' + y : y
        return y + '-' + m + '-' + day
      },
    },
    conputed: {},
    methods: {
      rem() {
        layer.confirm(
          '确认退出？',
          {
            btn: ['确认', '取消'], //可以无限个按钮
          },
          function (index, layero) {
            //按钮【按钮一】的回调
            localStorage.clear()
            history.go(0)
          },
          function (index) {
            //按钮【按钮二】的回调
          },
        )
      },
    },
  })
}

let loc = location.search.substring(1).split('=')
console.log(loc[1])
get(loc[1])
